package com.lcc.lynx.base.system.service.impl;

import com.lcc.lynx.base.system.mapper.SysDictMapper;
import com.lcc.lynx.base.system.pojo.dv.SysDictDV;
import com.lcc.lynx.base.system.pojo.dv.SysDictDtlDV;
import com.lcc.lynx.base.system.service.SysDictDtlService;
import com.lcc.lynx.base.system.service.SysDictService;
import com.lcc.lynx.common.utils.AssertUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** 
 * 字典表服务实现
 * @auth lcc
 * @date 2025-01-01
 */
@Service
@Transactional
@AllArgsConstructor
public class SysDictServiceImpl implements SysDictService {

    private SysDictMapper mapper;

    private SysDictDtlService dictDtlService;


    @Override
    public SysDictMapper getMapper() {
       return mapper;
    }

    @Override
    public SysDictDV getByCode(String code) {
        AssertUtil.isNotEmpty(code, "字典code不能为空");
        SysDictDV p = new SysDictDV();
        p.setDictCode(code);
        SysDictDV sysDictDV = this.selectOne(p);
        if(sysDictDV != null){
            SysDictDtlDV dv = new SysDictDtlDV();
            dv.setDictId(sysDictDV.getDictId());
            sysDictDV.setDtlDVList(dictDtlService.getMapper().select(dv));
            return sysDictDV;
        }
        return null;
    }
}